#include <functional>
#include <vector>

class Events
{
public:
    typedef std::function<void(void* param)> OnEvent;
public:
    Events& operator += (const OnEvent& evt)
    {
        events.push_back(evt);
        return (*this);
    }

    Events& operator -= (const OnEvent& evt)
    {
        for(auto it = events.begin(); it != events.end();)
        {
            if((*it) == evt)
            {
                it = events.erase(it);
            }
            else
                ++it;
        }
        return (*this);
    }

    void fire(void* param)
    {
        for(auto i : events)
        {
            i(param);
        }
    }
private:
    std::vector<OnEvent> events;
};

#define BIND_MEMBER_FUNCTION(fun) std::bind(&fun, this, std::placeholders::_1)